import { Injectable } from '@nestjs/common';
import { CreateFactoryBaseDto } from './dto/create-factoryBase.dto';
import { UpdateFactoryBaseDto } from './dto/update-factoryBase.dto';
import sequelize from '../../util/sequelize';
import { getSnowflakeId, snowflake } from '../../util';
import { CommonResult } from '../../util/commonResult';
import { FactoryBase } from '../../dao/FactoryBase';

@Injectable()
export class FactoryBaseService {
  private FactoryBase: typeof FactoryBase;

  constructor() {
    this.FactoryBase = FactoryBase.initModel(sequelize);
  }

  async create(createFactoryDto: CreateFactoryBaseDto) {
    await this.FactoryBase.create({
      id: getSnowflakeId(),
      ...createFactoryDto,
    });
    return CommonResult.success();
  }

  findAll() {
    return `This action returns all factory`;
  }

  findOne(id: number) {
    return `This action returns a #${id} factory`;
  }

  update(id: number, updateFactoryDto: UpdateFactoryBaseDto) {
    return `This action updates a #${id} factory`;
  }

  remove(id: number) {
    return `This action removes a #${id} factory`;
  }
}
